﻿using MyApp.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

namespace MyApp
{
  public class ScreenShareBusiness
  {
    private string exeFile = "ffmpeg_ScreenShare.exe";
    private string exePara = @"-f gdigrab -framerate 15 -i desktop -f flv rtmp://54.67.55.252:5130/live/flashtest1/";
    private string homePath = "";
    public string ExeFilePath
    {
      get
      {
        return Path.Combine(homePath, exeFile);
      }
    }
    public string ExePara
    {
      get
      {
        return exePara;
      }
    }
    public ScreenShareBusiness()
    {
      homePath = AppDomain.CurrentDomain.BaseDirectory;
    }
    public void StartProcess()
    {
      if (IsRunning())
      {
        StopProcess();
      }
      ProcessUtils.StartProcess(ExeFilePath, ExePara);
    }
    public bool IsRunning()
    {
      bool status = false;
      Process process = ProcessUtils.FindOne(exeFile);
      if (process != null)
        status = true;
      else
        status = false;
      return status;
    }
    public void StopProcess()
    {
      ProcessUtils.Kill(exeFile);
    }
  }
}
